/*
 * Yet Another Haxe Library, Copyright (c) 2009, Jean-Philippe CIMAN (Jeanffy)
 * All rights reserved.
 * Permission is hereby granted to use, copy, modify, and distribute this
 * source code, or portions hereof, for any purpose, without fee, subject
 * to the following restrictions:
 *
 * 1. The origin of this source code must not be misrepresented.
 * 2. Altered versions must be plainly marked as such and
 *    must not be misrepresented as being the original source.
 * 3. This copyright notice may not be removed or altered from
 *    any source or altered source distribution.
 *
 * If you use this source code in a product, acknowledgment is not
 * required but would be appreciated.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE PROJECT AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/**
	This class represents a 2D point
**/
class YahPoint
{
	public var x:Float;
	public var y:Float;
	
	public function new(?_x:Float, ?_y:Float)
	{
		x = 0;
		if (_x != null)
			x = _x;
		y = 0;
		if (_y != null)
			y = _y;
	}
	
	/** Defines the point **/
	public function set(_x:Float, _y:Float)
	{
		x = _x;
		y = _y;
	}
	
	/** Defines the point from another point **/
	public function setFrom(otherPoint:YahPoint)
	{
		x = otherPoint.x;
		y = otherPoint.y;
	}
	
	/** Returns the distance between two points TODO may be redundant with YahStd **/
	public function distance(other:YahPoint):Float
	{
		var dx:Float = x - other.x;
		var dy:Float = y - other.y;
		return Math.sqrt(dx*dx + dy*dy);
	}
	
#if debug
	public function dump()
	{
		trace("YahPoint : (" + x + ", " + y + ")");
	}
#end
}
